/*
 * RegistrarMasc.java
 *
 * Created on 10 de abril de 2008, 08:38 AM
 */

package mascotrin;
import java.sql.*;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.text.MaskFormatter;
/**
 *
 * @author  SQL
 */
public class RegistrarMasc extends javax.swing.JPanel {
    
    /** Creates new form RegistrarMasc */
    public RegistrarMasc() {
        initComponents();
        TextoMascara();
    }
    JFormattedTextField fecha;
    JFormattedTextField peso;
    public void TextoMascara()
    {
         try{
         JLabel lblFecha = new JLabel();
         lblFecha.setText("Fecha Nacimiento");
         MaskFormatter mask = new MaskFormatter("##/##/####");
         //  mask.setValidCharacters(".");
         fecha = new JFormattedTextField(mask);
        // fecha.setFormatterFactory(Integer);
         peso = new JFormattedTextField(new Double(0));
         DatosMascota.add(peso);
         DatosMascota.add(lblFecha);
         DatosMascota.add(fecha);
         
        }
        catch (java.text.ParseException e) {
            
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        DatosMascota = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));

        DatosMascota.setLayout(new java.awt.GridLayout(9, 2, 0, 7));

        jLabel1.setText("IDCliente");
        DatosMascota.add(jLabel1);
        DatosMascota.add(jTextField1);

        jLabel2.setText("Nombre");
        DatosMascota.add(jLabel2);
        DatosMascota.add(jTextField2);

        jLabel3.setText("Raza");
        DatosMascota.add(jLabel3);
        DatosMascota.add(jTextField3);

        jLabel4.setText("Tamaño");
        DatosMascota.add(jLabel4);

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "chico", "mediano", "grande" }));
        DatosMascota.add(jComboBox2);

        jLabel5.setText("Color");
        DatosMascota.add(jLabel5);
        DatosMascota.add(jTextField5);

        jLabel7.setText("Pelo");
        DatosMascota.add(jLabel7);
        DatosMascota.add(jTextField8);

        jLabel8.setText("Sexo");
        DatosMascota.add(jLabel8);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Macho", "Hembra" }));
        DatosMascota.add(jComboBox1);

        jLabel6.setText("Peso");
        DatosMascota.add(jLabel6);

        add(DatosMascota);

        jButton1.setText("Registrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        String idCliente = jTextField1.getText();
        String nombre = jTextField2.getText();
        String raza = jTextField3.getText();
        String tamaño = jComboBox1.getSelectedItem().toString();
        String color = jTextField5.getText();
        double pesop = Double.parseDouble(peso.getText());
        String pelo = jTextField8.getText();
        String sexo = jComboBox2.getSelectedItem().toString();
        String fechanacimiento = fecha.getText();
        String SQL = "INSERT INTO Mascota VALUES('"+idCliente+"','"+nombre+"','"+raza+"','"+tamaño+"','"+color+"','"+pesop+"','"+pelo+"','"+sexo+"','"+fechanacimiento+"')";
        CambiosSQL sqlRM = new CambiosSQL(SQL);
        //limpio los text
        jTextField1.setText("");//idcliente
        jTextField2.setText("");//nombre
        jTextField3.setText("");//raza
        jTextField5.setText("");//color
        peso.setText("");//peso
        jTextField8.setText("");//pelo
    }//GEN-LAST:event_jButton1ActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel DatosMascota;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField8;
    // End of variables declaration//GEN-END:variables
    
}
